<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/taglibs.jsp"%>

<form action="${ctx}/sys/org/update" method="post">
    <table>
        <tbody>
            <tr>
                <td><label for="updateform-id">组织ID</label></td>
                <td><input type="text" id="updateform-id" name="id" value="${org.id}" readonly="readonly" class="easyui-textbox"
                        data-options="validType:'length[0,32]', prompt:'不输入时会自动生成'"/>
                </td>
            </tr>
            <tr>
                <td><label for="updateform-orgType">组织类型</label></td>
                <td><input type="text" id="updateform-orgType" name="orgType" value="${org.orgType}" readonly="readonly" class="easyui-textbox"
                        data-options="required:true"/>
                </td>
            </tr>
            <tr>
                <td><label for="updateform-name">组织名</label></td>
                <td><input type="text" id="updateform-name" name="name" value="${org.name}" class="easyui-textbox"
                        data-options="required:true"/>
                </td>
            </tr>
            <tr>
                <td><label for="updateform-order">排序号</label></td>
                <td><input type="text" id="updateform-order" name="order" value="${org.order}" class="easyui-textbox"
                        data-options="validType:'number'"/>
                </td>
            </tr>
            <tr>
                <td><label for="updateform-parentId">上级组织</label></td>
                <td><input type="text" id="updateform-parentId" name="parentId" value="${org.parentId}" class="easyui-textbox"
                        data-options="validType:'length[0,32]'"/>
                </td>
            </tr>
        </tbody>
    </table>
</form>

<script type="text/javascript">
$(function(){
    var $parentId = $('#updateform-parentId').combotree({
        url: ctx + '/sys/org/list-available-parents-by-id',
        queryParams: {
            tree: true,
            orgId: '${org.id}'
        },
        lines: true,
        formatter: function(node) {
            return node.name || node.id;
        },
        onLoadSuccess: function(node, data) {
            var node = $parentId.combotree('tree').tree('find', '${org.parentId}');
            $parentId.combotree('setValue', node.id).combo('setText', node.name);
        },
        onClick: function(node) {
            $parentId.combotree('setValue', node.id).combo('setText', node.name);
        }
    });
});
</script>
